<extend name="common:base" />

<block name="content">
    <div style="height: 32px;">
        <ul class="nav nav-tabs pull-left">
            <li class="active"><a href="{{:url('turntable/index')}}" class="index-url">大转盘</a></li>
        </ul>
        <form name="searchForm" class="form-inline pull-left" action="{{:url('turntable/index')}}" method="get" style="margin-top: -2px; margin-left: 20px;">
            <div class="form-group">
                <label class="sr-only">这里不显示</label>
                <div class="input-group">
                    <div class="input-group-addon">shop_id</div>
                    <input type="text" name="shop_id" value="{{$shop_id}}" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="sr-only">这里不显示</label>
                <div class="input-group">
                    <div class="input-group-addon">turntable_id</div>
                    <input type="text" name="turntable_id" value="{{$turntable_id}}" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="sr-only">这里不显示</label>
                <div class="input-group">
                    <div class="input-group-addon">status</div>
                    <select id='status' name="status" class="form-control">
                        <option value ="2" <?php echo $status == 2 ? selected : ''; ?>>全部</option>
                        <option value ="1" <?php echo $status == 1 ? selected : ''; ?>>显示</option>
                        <option value ="0" <?php echo $status == 0 ? selected : ''; ?>>隐藏</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="sr-only">这里不显示</label>
                <div class="input-group">
                    <div class="input-group-addon">发布时间</div>
                    <input type="text" name="startime" value="{{$startime}}" id="datetime_start" class="form-control" style="width: 120px;" readonly>
                    <div class="input-group-addon">~</div>
                    <input type="text" name="endtime" value="{{$endtime}}" id="datetime_end" class="form-control" style="width: 120px;" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="sr-only">这里不显示</label>
                <div class="input-group">
                    <div class="input-group-addon">开始时间</div>
                    <input type="text" name="start_date" value="{{$start_date}}" id="datetime_start2" class="form-control" style="width: 120px;" readonly>
                    <div class="input-group-addon">~</div>
                    <input type="text" name="end_date" value="{{$end_date}}" id="datetime_end2" class="form-control" style="width: 120px;" readonly>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">搜索</button>
            <a href="{{:url('turntable/index')}}" class="btn btn-default">清空</a>
        </form>
    </div>

    <table class="table table-bordered table-hover top10" style="margin-bottom: 10px; font-size: 12px;">
        <tr class="table-header" style="background-color: #EFEFEF;">
            <th>turntable_id</th>
            <th>shop_id</th>
            <th>标题</th>
            <th style="width: 30%;">描述</th>
            <th>单人可玩次数</th>
            <th>排序/降序</th>
            <th>当天/活动总时间</th>
            <th>发布时间</th>
            <th>更新时间</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>中奖人数</th>
            <th>未中奖人数</th>
            <th>转盘总次数</th>
            <th style="text-align: center;">状态</th>
            <th style="text-align: center;">操作</th>
        </tr>
        <volist name="data" id="voart">
            <tr>
                <td>{{$voart.turntable_id}}</td>
                <td>{{$voart.shop_id}}</td>
                <td>{{$voart.title}}</td>
                <td>{{$voart.description}}</td>
                <td>{{$voart.num_by_one}}</td>
                <td>{{$voart.listorder}}</td>
                <td>{{$voart.frequncy}}</td>
                <td>{{$voart.created|date='Y-m-d',###}}</td>
                <td>{{$voart.updated|date='Y-m-d',###}}</td>
                <td>{{$voart.start_date|date='Y-m-d',###}}</td>
                <td>{{$voart.end_date|date='Y-m-d',###}}</td>
                <td>{{$voart.win_num}}</td>
                <td>{{$voart.no_win_num}}</td>
                <td>{{$voart.all_num}}</td>
                <td style="text-align: center;">
                    <eq name="voart.status" value="1">
                        <a class="btn btn-success btn-xs btn-editstatus" data-url="edit_status?status=0&turntable_id={{$voart.turntable_id}}">显示</a>
                        <else/>
                        <a class="btn btn-default btn-xs btn-editstatus" data-url="edit_status?status=1&turntable_id={{$voart.turntable_id}}">隐藏</a>
                    </eq>
                </td>
                <td style="text-align: center;">
                    <a href="{{:url('turntable/prize_list', array('turntable_id' => $voart['turntable_id']))}}" class="btn btn-warning btn-xs">奖品列表</a>
                </td>
            </tr>
        </volist>
        <tr class="table-header" style="background-color: #EFEFEF;">
            <th>turntable_id</th>
            <th>shop_id</th>
            <th>标题</th>
            <th style="width: 30%;">描述</th>
            <th>单人可玩次数</th>
            <th>排序/降序</th>
            <th>当天/活动总时间</th>
            <th>发布时间</th>
            <th>更新时间</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>中奖人数</th>
            <th>未中奖人数</th>
            <th>转盘总次数</th>
            <th style="text-align: center;">状态</th>
            <th style="text-align: center;">操作</th>
        </tr>
    </table>
    <div class="page-info">
        <div id="page_info"></div>
        <input type="hidden" id="allpages" value="{{$allpages}}" />
        <input type="hidden" id="nowpage" value="{{$nowpage}}" />
    </div>
</block>

<block name="footer">
    <script src="/static/js/laypage/laypage.js"></script>
    <script>
        // console.log(document.getElementById('status'));
        // var mySelect = document.getElementById('status');
        // var index = mySelect.selectedIndex;
        // mySelect.options[index].value = 1;
        // mySelect.options[index].text = "显示";
        //
        // console.log($("#status option:selected").text())
        //
        // console.log($("#status").find('option:selected').text())
        //
        // console.log($("#status").val());
        // console.log($("#status").get(0).selectedindex)
        // 清空 cookie 上一页 url
        $.cookie('edit_back_referrer', '', {path: '/'});

        // 实例化时间控件 laydate
        laydate.render({
            elem: '#datetime_start', //指定元素
            format: 'yyyy-MM-dd',
        });
        laydate.render({
            elem: '#datetime_end', //指定元素
            format: 'yyyy-MM-dd',
        });
        laydate.render({
            elem: '#datetime_start2', //指定元素
            format: 'yyyy-MM-dd',
        });
        laydate.render({
            elem: '#datetime_end2', //指定元素
            format: 'yyyy-MM-dd',
        });
        // ajax 分页
        laypage({
            cont: 'page_info',
            pages: $('body #allpages').val(),
            curr: function(){
                var page = $('body #nowpage').val();
                return page ? page : 1;
            }(),
            skip: true, // 分页跳转
            jump: function(e, first){
                if(!first){
                    layer.load(0, {shade: [0.1, '#FFF']}); // 加载层
                    var formData = $('form[name="searchForm"]').serialize();
                    var url = 'index?page=' + e.curr + '&' + formData;

                    window.location.href = url;
                    return false;
                }
            }
        });
    </script>
</block>